package com.softline.documentsmall.controller;

import com.softline.documentsmall.entity.HotIssues;
import com.softline.documentsmall.entity.IssuesAnswer;
import com.softline.documentsmall.ret.ReturnVO;
import com.softline.documentsmall.ret.ReturnVOUtils;
import com.softline.documentsmall.service.HotIssuesService;
import com.softline.documentsmall.service.IssuesAnswerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author zhongweicheng
 * @date 2020/8/25 10:11
 */
@Api(value="问题回答相关接口",tags={"问题回答相关接口"})
@RestController
@RequestMapping("/issuesAnswer")
@CrossOrigin(allowCredentials = "true",allowedHeaders = "*")
public class IssuesAnswerController {

    @Autowired
    IssuesAnswerService hotIssuesService;

    @ApiOperation(value="按照条件获取问题回答列表", notes = "按照条件获取问题回答列表")
    @GetMapping(value = "/getIssuesAnswer")
    public ReturnVO getIssuesAnswer(Integer id,Integer issuesId, String content,String passportId,Integer approveState,Integer isDelete,Integer currPage,Integer pageSize,String startDate,String endDate){

        return hotIssuesService.findByParams(id,issuesId,content,passportId,approveState,isDelete,currPage,pageSize,startDate,endDate);
    }

    @ApiOperation(value="更新问题回答", notes = "更新问题回答,须传递id")
    @PostMapping(value = "/updateIssuesAnswer")

    public ReturnVO update(@RequestBody @Valid IssuesAnswer hotIssues){

        return hotIssuesService.updateIssueAnswerById(hotIssues);
    }



    @ApiOperation(value="新增问题回答", notes = "新增问题回答")
    @PostMapping(value = "/insertIssuesAnswer")
    public ReturnVO insert(@RequestBody IssuesAnswer hotIssues){

        return hotIssuesService.insertIssueAnswer(hotIssues);
    }


    //管理员删除超级权限
    @ApiOperation(value="软删除回答根据id", notes = "软删除回答根据id")
    @PostMapping(value = "/softDeleteIssueAnswerById")
    public ReturnVO softDeleteIssueAnswer(Integer id){

        return hotIssuesService.softDeleteIssueAnswerById(id);
    }

    @ApiOperation(value="根据id,更新是否批准状态(用于管理员后台管理)", notes = "根据id,更新是否批准状态(用于管理员后台管理)")
    @PostMapping(value = "/updateApproveStateById")
    public ReturnVO updateApproveStateById(Integer id,Integer approveState){

        return hotIssuesService.updateApproveStateById(id,approveState);
    }

    @ApiOperation(value="软删除回答根据问题id(批量)", notes = "软删除回答根据问题id(批量)")
    @PostMapping(value = "/softDeleteIssueAnswerByIssuesId")
    public ReturnVO softDeleteIssueAnswerByIssuesId(Integer issuesId){

        return hotIssuesService.softDeleteIssueAnswerByIssueId(issuesId);
    }



}
